package org.eae.eldf.dao.base.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.eae.eldf.dao.base.IBaseCompanyLinkmanDao;
import org.eae.eldf.entity.base.BaseCompanyLinkman;
import org.eae.eldf.framework.dao.JdbcDaoImpl;
import org.eae.eldf.framework.pager.Pagination;
import org.springframework.stereotype.Repository;
@Repository
public class BaseCompanyLinkmanDaoImpl extends JdbcDaoImpl implements IBaseCompanyLinkmanDao {

	@Override
	public Pagination<BaseCompanyLinkman> pageLinkmanList(Pagination<BaseCompanyLinkman> pager, String searchValue) {
		// TODO Auto-generated method stub
		List<Object> list= new ArrayList<Object>();
		StringBuffer sql =new StringBuffer(" select bcl.* from base_company_linkman  bcl where  bcl.valid=1 ");
		if(StringUtils.isNotBlank(searchValue)){
			sql.append(" and bcl.company_code like ? ");
			list.add("%"+searchValue.toLowerCase()+"%");
		}
		if (StringUtils.isNotBlank(pager.getOrderBy())&& StringUtils.isNotBlank(pager.getSort())) {
			sql.append(" order by "+pager.getOrderBy()+" "+pager.getSort());
		}
		else {
			sql.append("order by create_time desc");
		}
		return this.queryListByPage(pager, sql.toString(),list,BaseCompanyLinkman.class);
	}

	

	@Override
	public List<BaseCompanyLinkman> findLinkmanByCompanyCode(
			String baseCompanyCode) {
		// TODO Auto-generated method stub
		List<Object> pars=new ArrayList<Object>();
		StringBuffer sql = new StringBuffer("select * from base_company_linkman bcl where bcl.company_code = ? and valid =1");
		pars.add(baseCompanyCode);
		//return this.queryBySQL(sql.toString(), BaseCompanyLinkman.class);
		return this.queryBySQL(sql.toString(), pars, BaseCompanyLinkman.class);
	}

}
